﻿@using Kevin.Shop.Business.SalesManagement.Enumerations
@model RiderShop.Mobile.ServiceEntity.MyAccount.OrderBasicInfoExtend
@{
    Layout = "../Shared/_MobileLayout.cshtml";
}
@section header
{
    <style>
        .myAccountActive {
            color: #ff6c1f;
        }

        .financial-table-reflow {
            width: 100%;
        }

        .front-mask {
            background-color: rgba(0,0,0,0.5);
            position: fixed;
            top: 0px;
            left: 0px;
            width: 100%;
            height: 100%;
            z-index: 99;
            display: none;
            text-align: center;
            z-index: 1;
        }

        .front-mask-content {
            max-width: 80%;
            background-color: white;
            margin: 15% auto;
            text-align: left;
            padding: 20px;
            border-radius: 4px;
        }

        .ui-grid-a {
            padding: 10px 0;
        }

        .front-mask-content textarea, .front-mask-content select {
            width: 100%;
        }

        .la {
            float: left;
            width: 48%;
        }

        .ra {
            float: right;
            width: 48%;
        }
    </style>

}
@section title
{
    订单详情
}
@section pagetitle
{
    订单详情
}
<div class="userCenterHeader">
    <span class="iconWrapper">
        <img src="~/Themes/RongJi/Style/base/imgs/icon_zhang.png">
    </span>
    <h3>订单详情</h3>
    <br class="clearfix">
</div>
<div class="box">
    <div class="groupbox">
        <div class="OtherTitle">
            <div class="TitleLeft mt10 f15">基本信息</div>
        </div>
        <div class="ItemTable">
            <div class="TitleLeft">
                <fieldset data-role="controlgroup" class="ui-corner-all ui-controlgroup ui-controlgroup-vertical" aria-disabled="false" data-disabled="false" data-shadow="false" data-corners="true" data-exclude-invisible="true" data-type="vertical" data-mini="false" data-init-selector=":jqmData(role='controlgroup')">
                    <div class="ui-controlgroup-label" role="heading"><legend></legend></div>
                    <div class="ui-controlgroup-controls">

                        <div class="mb5 ml10">
                            <ul id="orderListTitle">
                                <li class="mb5">
                                    <span class="tit">订单编号：</span><span class="info">@Model.OrderNumber</span>
                                    <input type="hidden" value="@Model.OrderNumber" id="hidn_orderNumber">
                                </li>
                                <li class="mb5">
                                    <span class="tit">状态：</span><span class="info red f15">@Model.OrdeStatusName</span>
                                </li>
                                <li class="mb5">
                                    <span class="tit">下单日期：</span><span class="info">@Model.OrderDate</span>
                                </li>
                                <li class="mb5">
                                    <span class="tit">客户备注：</span><span class="info normalwrap">@Model.UserMemo</span>
                                </li>
                            </ul>
                        </div>
                    </div>
                </fieldset>
            </div>
        </div>
        <div class="OtherTitle">
            <div class="TitleLeft mt10 f15">收货信息</div>
        </div>
        <div class="ItemTable">
            <div class="TitleLeft">
                <fieldset data-role="controlgroup" class="ui-corner-all ui-controlgroup ui-controlgroup-vertical" aria-disabled="false" data-disabled="false" data-shadow="false" data-corners="true" data-exclude-invisible="true" data-type="vertical" data-mini="false" data-init-selector=":jqmData(role='controlgroup')">
                    <div class="ui-controlgroup-label" role="heading"><legend></legend></div>
                    <div class="ui-controlgroup-controls">

                        <div class="mb5 ml10">
                            <ul id="orderListTitle">
                                <li class="mb5">
                                    <span class="tit">收货人：</span><span class="info">@Model.CustomerUserName</span>
                                </li>
                                @*<li class="mb5">
                                        <span class="tit">电话：</span><span class="info">@Model.ReceivePhone &nbsp;</span>
                                    </li>*@
                                <li class="mb5">
                                    <span class="tit">手机：</span><span class="info">@Model.ReceiveCellPhone &nbsp;</span>
                                </li>
                                <li class="mb5">
                                    <span class="tit">地区：</span><span class="info">@Model.FullRegionName &nbsp;</span>
                                </li>
                                <li class="mb5">
                                    <span class="tit">地址：</span><span class="info">@Model.ReceiveAddress</span>
                                </li>
                            </ul>
                        </div>
                    </div>
                </fieldset>
            </div>
        </div>
        <div class="OtherTitle">
            <div class="TitleLeft mt10 f15">支付方式</div>
        </div>
        <div class="ItemTable">
            <div class="TitleLeft">
                <fieldset data-role="controlgroup" class="ui-corner-all ui-controlgroup ui-controlgroup-vertical" aria-disabled="false" data-disabled="false" data-shadow="false" data-corners="true" data-exclude-invisible="true" data-type="vertical" data-mini="false" data-init-selector=":jqmData(role='controlgroup')">
                    <div class="ui-controlgroup-label" role="heading"><legend></legend></div>
                    <div class="ui-controlgroup-controls">

                        <div class="mb5 ml10">
                            <ul>
                                <li class="mb5">
                                    <span class="tit">支付方式：</span><span class="info">@Model.ArrivePayName</span>
                                </li>
                                <li class="mb5">
                                    <span class="tit">配送方式：</span><span class="info">@Model.ShippingModeName</span>
                                </li>
                                @if (!string.IsNullOrWhiteSpace(Model.ShipLogisticsCompanyName))
                                {
                                    <li class="mb5">
                                        <span class="tit">物流公司：</span><span class="info">@Model.ShipLogisticsCompanyName</span>
                                    </li>
                                    <li class="mb5">
                                        <span class="tit">运单号码：</span><span class="info">@Model.ShipOrderNumber</span>
                                    </li>
                                }
                            </ul>
                        </div>
                    </div>
                </fieldset>
            </div>
        </div>

        <div class="OtherTitle">
            <div class="TitleLeft mt10 f15">商品列表</div>
        </div>
        <div class="ItemTable">
            <div class="ItemTableRight">
                @*<div class="OtherProductItem" id="OtherProductRight">*@
                <fieldset data-role="controlgroup" class="ui-corner-all ui-controlgroup ui-controlgroup-vertical" aria-disabled="false" data-disabled="false" data-shadow="false" data-corners="true" data-exclude-invisible="true" data-type="vertical" data-mini="false" data-init-selector=":jqmData(role='controlgroup')">
                    <div class="ui-controlgroup-label" role="heading"><legend></legend></div>
                    <div class="ui-controlgroup-controls">
                        <div class="mb5 p0_10">
                            @foreach (var item in Model.ProductList)
                            {

                                <div class="OtherTitle">
                                    <div class="TitleLeft mt5"><span class="TitleLeftSpan p10_0">商品:@item.ProductId</span></div>
                                    <div class="TitleRight">
                                        <div name="EditQtyAfter" class="ItemQtySpan">
                                            <div class="ItemQty">
                                                <span class="qtyLable">数量：</span>
                                                <div id="Qty_11-119-225" class="QtyTable">@item.Quantity</div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="ItemTable">
                                    <div id="OtherProductRight" class="ItemTableRight">
                                        <div class="OtherProductItem">

                                            @if (item.ProductId.Trim() == "COM")
                                            {
                                                <div class="ItemLeft">
                                                    <img src="http://dev.rongji365.com/Storage/CommResource/COM/COM_100.jpg" alt="" />
                                                </div>
                                                <div class="ItemRight"><span class="ItemRightWrod">@item.ProductName</span></div>
                                            }
                                            else
                                            {
                                                <a href="~/Product/ProductDetail?prd=@item.ProductId" class="product-listlink">
                                                    <div class="ItemLeft">
                                                        <img src="@item.ImageName" alt="" />
                                                    </div>
                                                    <div class="ItemRight"><span class="ItemRightWrod">@item.ProductName</span></div>
                                                </a>
                                            }
                                            <br class="clearfix">
                                        </div>
                                        <div class="ProductPrice">
                                            <span id="prd_price_000" class="Price">@item.Quantity x @item.UnitPrice = ￥@(item.Quantity * item.UnitPrice)</span>
                                        </div>
                                    </div>
                                </div>

                            }
                        </div>
                    </div>
                </fieldset>
                @*</div>*@
            </div>

            <div class="OtherTitle">
                <div class="TitleLeft mt10 f15">物流跟踪</div>
            </div>
            <div class="ItemTable">
                <div class="ItemTableRight">
                    <fieldset data-role="controlgroup" class="ui-corner-all ui-controlgroup ui-controlgroup-vertical" aria-disabled="false" data-disabled="false" data-shadow="false" data-corners="true" data-exclude-invisible="true" data-type="vertical" data-mini="false" data-init-selector=":jqmData(role='controlgroup')">
                        <div class="ui-controlgroup-label" role="heading"><legend></legend></div>
                        <div class="ui-controlgroup-controls">
                            <div class="mb5 ml10">
                                <table class="orderTrace" style="width: 100%;">
                                    <thead>
                                        <tr>
                                            <th></th>
                                        </tr>
                                    </thead>
                                    <tbody>

                                        <tr>
                                            <td>
                                                <div class="fontweight">
                                                    <span class="proDate">处理时间</span>
                                                    <span class="proNote">处理信息</span>
                                                </div>
                                            </td>
                                        </tr>

                                        @foreach (var orderProcessLog in Model.OrderProcessLogList)
                                        {
                                            <tr>
                                                <td>
                                                    <div class="textoverhid">
                                                        <span class="proDate">@orderProcessLog.InDateFormated</span>
                                                        <span class="textoverhid proNote">@orderProcessLog.ProcessNote</span>
                                                    </div>
                                                </td>
                                            </tr>
                                        }

                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </fieldset>
                </div>
            </div>
            <div class="checkoutDiscount tline">
                <div class="total">
                    <div class="totalinfo">
                        <p><span class="tit">小计：</span><span class="case">@Model.OrderItemTotalCost</span></p>
                        <p><span class="tit">运费金额：</span><span class="case" id="ShippingCharge">@Model.ShippingCharge</span></p>
                        <p><span class="tit">积分抵扣：</span><span class="case green" id="GiftCardAmount">-@Model.OrderExpenseAmount</span></p>
                        <p><span class="tit">订单折扣：</span><span class="case green" id="DiscountAmount">-@Model.DiscountAmount</span></p>
                        <p><span class="tit">余额抵扣：</span><span class="case green" id="ExpenseAmount">-@Model.OrderGiftCardAmount</span></p>
                        <p class="all"><span class="tit">应付金额：</span><span>@Model.OrderPayAmount  </span></p>
                    </div>
                </div>
            </div>

        </div>
    </div>

    @if (Model.OrderStatus == Kevin.Shop.Business.SalesManagement.Enumerations.OrderStatus.待确认
    || Model.OrderStatus == Kevin.Shop.Business.SalesManagement.Enumerations.OrderStatus.待支付)
    {
        <form method="GET" id="voidOrderForm" action="~/MyAccount/VoidOrder">
            @if (Model.OrderStatus == OrderStatus.待支付)
            {
                @*if (Request.UserAgent.Contains("MicroMessenger") && !string.IsNullOrEmpty(Model.PaymentGateway) && Model.PaymentGateway.ToUpper() == "WEIXINPAY")
                    {
                        <a class="btn btn-success la" href="@(string.Format(System.Configuration.ConfigurationManager.AppSettings["WeixinPayAddress"], Model.OrderNumber.Trim()))" data-theme="a" data-role="button">微信支付</a>
                    }
                    else if (!string.IsNullOrEmpty(Model.PaymentGateway) && Model.PaymentGateway.ToUpper() == "RONGJICART")
                    {
                        <a class="btn btn-danger la" href="~/Purchase/YinxinPay?orderNumber=@Model.OrderNumber.Trim()&orderType=1" data-theme="a" data-role="button">鲜享卡付款</a>
                    }
                    else
                    {
                        <a class="btn btn-danger la" href="~/Purchase/Payment?orderNumber=@Model.OrderNumber.Trim()&orderType=1" data-theme="a" data-role="button">支付宝付款</a>
                    }*@

                <a class="btn btn-info  ra" href="javascript:void(0)" id="cancelOrder" data-role="button" data-rel="popup">取消订单</a>
                <a class="btn btn-danger la" href="@("/Purchase/OrderCompleted?par=" + @Model.OrderNumber.Trim() + ",100,0&payonly=1")" data-theme="a" data-role="button">立即付款</a>

            }
            else
            {
                <a class="btn btn-info ra" href="javascript:void(0)" id="cancelOrder" data-role="button" data-rel="popup">取消订单</a>
                <a class="btn btn-default la" id="linkToOrderListForm" href="~/MyAccount/OrderList" data-role="button">返回</a>
            }
        </form>
    }
    else if (Model.OrderStatus >= OrderStatus.已付款 && Model.OrderStatus <= OrderStatus.已结束
            && Model.OrderDate.HasValue && Model.OrderDate.Value.AddDays(7) > DateTime.Now)
    {
        <a class="btn btn-danger btn-block la" href="/Promotion/GetGameView?orderNumber=@Model.OrderNumber.Trim()" data-theme="a" data-role="button">玩游戏</a>
    }
    @if (Model.OrderType == 6 && Model.OrderStatus == OrderStatus.已付款 && Model.RegionId <= 0)
    {
        <a class="btn btn-danger btn-block ra" href="~/Purchase/PaymentCompleted?orderNumber=@Model.OrderNumber.Trim()&orderType=6" data-theme="a" data-role="button">送朋友</a>
        @*<a class="btn btn-default ra" id="linkToOrderListForm" href="~/MyAccount/OrderList" data-role="button">返回</a>*@
    }
</div>


<div id="voidOrderPopup" class="front-mask">
    <div class="front-mask-content">
        <fieldset data-role="controlgroup">
            <legend>订单： @Model.OrderNumber</legend>
            <select id="voidOrderType" class="select">
                <option value="" selected="selected">请选择取消原因</option>
                <option value="0">现在不想购买</option>
                <option value="1">支付不成功</option>
                <option value="2">商品价格较贵</option>
                <option value="3">等待时间过长</option>
                <option value="4">有商品缺货</option>
                <option value="5">更换或添加新商品</option>
                <option value="6">错误或重复下单</option>
                <option value="7">其它原因</option>
            </select>
            <textarea cols="40" rows="4" name="voidReason" id="voidReason" maxlength="40" placeholder="请简要说明原因(选填)" class="form-control"></textarea>
        </fieldset>
        <div class="ui-grid-a">
            <a href="javascript:void(0)" onclick="CancelOrder()" class="btn btn-danger la" data-role="button">确定</a>
            <a href="javascript:void(0)" onclick="CloseWindow()" class="btn btn-info ra" data-role="button">关闭</a>
            <br class="clearfix">
        </div>
    </div>
</div>
@section footer
{
    <script language="javascript" type="text/javascript">
        //OrderCompleted.html
        $("#cancelOrder").click(function () {
            //$('#voidOrderPopup').popup('open');
            $('#voidOrderPopup').show();
        });


        function CloseWindow() {
            //    //不知道为啥，需要执行两次才能关闭DIV
            //    $('#voidOrderPopup').popup('close');
            //    $('#voidOrderPopup').popup('close');
            $('#voidOrderPopup').hide();
        }

        $(function () {
            //让toolbar选中
            var $homeImg = $("#homeImg");
            var $categoryImg = $("#categoryImg");
            var $myaccountImg = $("#myaccountImg");
            var $searchImg = $("#searchImg");

            $homeImg.attr("src", "/Themes/RongJi/Style/base/imgs/f10.png");
            $categoryImg.attr("src", "/Themes/RongJi/Style/base/imgs/f2.png");
            $myaccountImg.attr("src", "/Themes/RongJi/Style/base/imgs/f3_c.png");
            $searchImg.attr("src", "/Themes/RongJi/Style/base/imgs/f4.png");
        });

        CancelOrder = function () {
            var orderNumber = $("#hidn_orderNumber").val();
            var orderVoidType = $("#voidOrderType").val();
            var orderVoidReason = $("#voidReason").val();

            if (!orderVoidType) {
                KevinShop.MessageBox.Alert('请选择取消原因！');
                return;
            }

            if (orderVoidType == 7
                && (orderVoidReason == null
                || orderVoidReason == '')) {
                KevinShop.MessageBox.Alert('请输入作废备注！');
                return;
            }

            if (window.confirm("您确定要取消订单吗？")) {
                var url = document.forms["voidOrderForm"].action;

                var voidOrder = {};
                voidOrder["orderNumber"] = orderNumber;
                voidOrder["voidType"] = orderVoidType;
                voidOrder["voidReason"] = orderVoidReason;

                KevinShop.Common.Ajax.Post(url, voidOrder, function (data) {
                    if (data.error) {
                        KevinShop.MessageBox.Alert(data.error);
                        return;
                    }
                    if (!data.Status) {

                        KevinShop.MessageBox.Alert(data.ErrorMessage);
                        return;
                    }
                    CloseWindow();

                    var url = "/MyAccount/OrderList";
                    window.location = url + "?orderType=3";

                }, false);
            }

            return false;
        };

    </script>
}